/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package grid;

/**
 *
 * @author Dragan
 */
public class BreederJob extends SingleJob {

    private static final String EXECUTABLE = "breeder.sh";
    private static final String CLASS = "grid.Breeder";

    public BreederJob(int seasons, int islands, int epoch, int island, int migrationWidth,
            String inputSanboxDir, String vo, int defaultNodeRetryCount, int defaultNodeShallowRetryCount, String rank) {
        super(vo, EXECUTABLE, CLASS + " " + seasons + " " + epoch + " " + island + " " + islands + " " + migrationWidth, defaultNodeRetryCount, defaultNodeShallowRetryCount, rank);
        if (!inputSanboxDir.endsWith("/") && inputSanboxDir.length() > 1) {
            inputSanboxDir += "/";
        }
        addInput("gridapp.jar");
        addInput("grid_queries");
        for (int i = -migrationWidth; i <= migrationWidth; i++) {
            int index = island + i <= 0 ? islands + island + i : island + i;
            index = index > islands ? index - islands : index;
            String inputFile = inputSanboxDir + "population" + index + "_" + epoch + ".gz";
            addInput(inputFile);
        }
        addOutput("breeder" + island + "_" + epoch + ".log.gz");
        addOutput("population" + island + "_" + epoch + "_out.gz");
    }

    public BreederJob(int seasons, int islands, int epoch, int island, int migrationWidth) {
        this(seasons, epoch, island, islands, migrationWidth, "", "", 0, 3, null);
    }

    public static void main(String[] args) {
        BreederJob breederJob = new BreederJob(1, 4, 2, 1, 1, "breeder1", "seegrid", 0, 3, "-other.GlueCEStateEstimatedResponseTime");

        breederJob.addRequirement("(other.GlueCEUniqueID ==\"grid-ce.ii.edu.mk:2119/jobmanager-pbs-seegrid\")");
        breederJob.addRequirement("(other.GlueCEUniqueID == \"grid-lab-ce.ii.edu.mk:2119/jobmanager-pbs-seegrid\")");

        System.out.println(breederJob);
    }
}
